<template>
    <div class="header">
        <div class="logo">后台管理系统</div>
        <div class="header-right">
            <div class="header-user-con">
                <!-- 用户头像 -->
                <div class="user-avator">
                    <img src="../assets/img/logo.png" />
                </div>
                <!-- 用户名下拉菜单 -->
                <el-dropdown class="user-name" trigger="hover" @command="handleCommand">
                    <span class="el-dropdown-link">
                        {{ username }}
                        <i class="el-icon-caret-bottom"></i>
                    </span>
                    <template slot="dropdown">
                        <el-dropdown-menu>
                            <el-dropdown-item command="user">个人中心</el-dropdown-item>
                            <el-dropdown-item divided command="loginout">退出登录</el-dropdown-item>
                        </el-dropdown-menu>
                    </template>
                </el-dropdown>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            username: '哈哈'
        }
    },
    methods: {
        // 下拉列表事件
        handleCommand(command) {
            switch (command) {
                case 'user':
                    break;
                case 'loginout':
                    break;
            }
        }
    }
}
</script>

<style lang="less" scoped>
.header {
    position: relative;
    width: 100%;
    height: 70px;
    background: #242f42;
    color: #fff;
    font-size: 22px;

    .logo {
        float: left;
        margin-left: 42px;
        line-height: 70px;
    }

    .header-right {
        float: right;
        padding-right: 50px;

        .header-user-con {
            display: flex;
            height: 70px;
            align-items: center;

            .user-avator {
                margin-left: 20px;
                width: 40px;
                height: 40px;

                img {
                    width: 100%;
                    height: 100%;
                    border-radius: 50%;
                }
            }

            .user-name {
                margin-left: 10px;

                .el-dropdown-link {
                    color: #fff;
                    cursor: pointer;
                }
            }


        }
    }
}
</style>